<!--奖励账号流水页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<!--        <el-form-item prop="tradeScene">-->
<!--          <ren-select v-model="dataForm.tradeScene" dict-type="tradeScene" placeholder="请选择场景类型"></ren-select>-->
<!--        </el-form-item>-->
<!--        <el-form-item prop="tradeType">-->
<!--          <ren-select v-model="dataForm.tradeType" dict-type="tradeType" placeholder="请选择交易类型"></ren-select>-->
<!--        </el-form-item>-->
        <el-form-item prop="grantStatus">
          <ren-select v-model="dataForm.grantStatus" dict-type="grant_status" placeholder="请选择发放状态"></ren-select>
        </el-form-item>
<!--        <el-form-item prop="deptId">-->
<!--          <el-input v-model="dataForm.deptId" type="text" placeholder="请输入部门ID" clearable></el-input>-->
<!--        </el-form-item>-->
        <el-form-item prop="formId">
          <el-input v-model="dataForm.formId" type="text" placeholder="请输入订单编号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker
              v-model="createDateList"
              type="daterange"
              placeholder="请选择创建日期"
              format="yyyy 年 MM 月 dd 日"
              range-separator="至"
              start-placeholder="开始创建日期"
              end-placeholder="结束创建日期"
              value-format="yyyy-MM-dd"
              class=""
              @change="createCK"
          />
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
        <el-form-item v-if="$hasPermission('api:deptAccountEdou:export')">
          <el-button @click="exportHandle()" type="info">导出</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('api:deptAccountEdou:save')" type="primary"
                     @click="addOrUpdateHandle()">
            新增
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('api:deptAccountEdou:delete')" type="danger" @click="deleteHandle()">
            删除
          </el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                ref="multipleTable" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
<!--        <el-table-column prop="deptId" label="公司信息" header-align="center" align="center"width="">-->
<!--          <template slot-scope="{}" slot="header">-->
<!--            &lt;!&ndash; 表头名称 &ndash;&gt;-->
<!--            <span>公司信息</span>-->
<!--            <el-tooltip class="item" effect="dark" placement="top">-->
<!--              <i class="el-icon-question" style="font-size:16px;"></i>-->
<!--              &lt;!&ndash; 悬停提示内容 &ndash;&gt;-->
<!--              <div slot="content">-->
<!--                <div>点击下方名称查看公司信息</div>-->
<!--              </div>-->
<!--            </el-tooltip>-->
<!--          </template>-->
<!--          <template slot-scope="{row}">-->
<!--            <el-tag size="small" type="info" style="cursor: pointer;" @click="showDepartmentList(row.sysDeptDTO)" v-if="row.sysDeptDTO">{{row.sysDeptDTO.name}}</el-tag>-->
<!--            <div v-if="!row.sysDeptDTO">{{row.deptId}}</div>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column prop="formId" label="订单编号" header-align="center" align="center" width="" show-overflow-tooltip></el-table-column>
        <el-table-column prop="tradeNum" label="奖励金额" header-align="center" align="center" width="" sortable show-overflow-tooltip></el-table-column>
<!--        <el-table-column prop="tradeScene" label="场景" header-align="center" align="center" width="" show-overflow-tooltip>-->
<!--          <template slot-scope="{row}">-->
<!--            <div size="small" type="info">{{-->
<!--                $getDictLabel("tradeScene", row.tradeScene)-->
<!--              }}-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column prop="tradeType" label="交易" header-align="center" align="center" width="" show-overflow-tooltip>-->
<!--          <template slot-scope="{row}">-->
<!--            <div>-->
<!--              {{ $getDictLabel("tradeType", row.tradeType) }}-->
<!--            </div>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column prop="tradeScene" label="奖励备注" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{row}">
            <div size="small" type="info">{{
                $getDictLabel("tradeScene", row.tradeScene)
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="grantStatus" label="发放状态" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{row}">
            <div>
              {{ $getDictLabel("grant_status", row.grantStatus) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
                <el-table-column label="操作" fixed="right" header-align="center" align="center" width="">
                  <template slot-scope="scope">
                    <el-link  v-if="$hasPermission('api:getOrder:query')" type="primary"
                                @click="getOrderList(scope.row)">关联订单</el-link>
                  </template>
                </el-table-column>

      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <user-order-product-list v-if="isUserOrderProductList" ref="UserOrderProductList" @cancellation="$refs.multipleTable.clearSelection()"></user-order-product-list>
      <!--查看公司信息组件-->
      <com-department-list :visible.sync="showDepartment" :content="content"></com-department-list>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userAccountEdouAddOrUpdate.vue'
import UserOrderProductList from "@/views/modules/service/userOrderProductList.vue";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/deptAccountEdou/page',
        getDataListIsPage: true,
        deleteURL: '/api/deptAccountEdou',
        deleteIsBatch: true,
        exportURL: '/api/deptAccountEdou/exportUserAccountEdou'             // 导出接口，API地址
      },
      showUser:false,                   //是否显示用户信息
      showDepartment:false,             //是否显示公司信息
      isUserOrderProductList: false,    //订单详情弹窗
      content:{},                       //用户信息内容
      createDateList: [],               //创建时间数组
      dataForm: {
        id: '',                         //id
        tradeNum:'',                    //交易数量
        tradeScene: '',                 //场景：购物商城、积分商城、签到
        tradeType: '',                  //交易：增加、减少
        grantStatus:'',                 //发放状态：未发放、已发放
        deptId: '',                     //用户唯一标识
        formId: '',                     //业务编号,消费订单或提现订单
        createDateStart: '',            //开始创建时间
        createDateEnd: '',              //结束创建时间
      },
    }
  },
  components: {
    UserOrderProductList,
    AddOrUpdate
  },
  created() {

  },
  methods: {
    /*创建时间选择*/
    createCK() {
      if (!this.createDateList){
        this.dataForm.createDateStart = ''
        this.dataForm.createDateEnd = ''
        return
      }
      this.dataForm.createDateStart = this.createDateList[0]
      this.dataForm.createDateEnd = this.createDateList[1]
    },
    //显示公司信息
    showDepartmentList(content){
      this.showDepartment=true;
      this.content= content;
    },
    //查看订单信息
    getOrderList(item){
      this.$refs.multipleTable.toggleRowSelection(item);
      this.isUserOrderProductList = true
      this.$nextTick(() => {
        this.$refs.UserOrderProductList.dataForm.id = item.formId
        this.$refs.UserOrderProductList.init()
      })
    },
  }
}
</script>
